home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / DTCODEBK.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  6.4 KB  |  221 lines

  1. #ifndef _DTCODEBK_HPP
  2. #define _DTCODEBK_HPP
  3.  
  4. #if defined( _DEBUG ) && defined( new )
  5. #   undef new
  6. #   undef delete
  7. #   define _REDEFINE_WNEW
  8. #endif
  9.  
  10. #include <wcvector.h>
  11.  
  12. #ifdef _REDEFINE_WNEW
  13. #   include "wnew.hpp"
  14. #endif
  15.  
  16. #include "mtdef.hpp"
  17.  
  18. class MMEvent;
  19. class WStringList;
  20. class SaveSource;
  21. class SaveBlock;
  22. class DTObject;
  23. class UserFunction;
  24. class ostream;
  25.  
  26. enum UFScope {
  27.     UFPublic,
  28.     UFPrivate,
  29.     UFProtected,
  30.     UFGeneratedPublic,     // C++ Only
  31.     UFPrivateProtected,    // Java only
  32.     UFDefault,             // Java only
  33.     UFEvent,               // Events are in Event scope.
  34. };
  35.  
  36. enum CMCodeBlock {
  37.     CMCHppPrefix,
  38.     CMCClassContents,
  39.     CMCGeneratedClassContents,
  40.     CMCHppSuffix,
  41.  
  42.     CMCCppPrefix,
  43.     CMCCppSuffix,
  44.  
  45.     CMCNumBlocks,
  46. };
  47.  
  48. enum CMFile {
  49.     CMFileHPP,
  50.     CMFileCPP,
  51.     CMFileJava,
  52.     CMFileNumFiles,
  53. };
  54.  
  55. enum CCType {
  56.     CCClassName,
  57.     CCFunctionName,
  58.     CCVariableUsage
  59. };
  60.  
  61.  
  62. class METACLASSDEF DTCodeBlockBase : public WObject
  63. {
  64.     public:
  65.         virtual WString         GetName() const = 0;
  66.         virtual const MMEvent * GetEventDef() const = 0;
  67.         virtual int operator == ( const DTCodeBlockBase & ) const = 0;
  68.         virtual int operator <  ( const DTCodeBlockBase & ) const = 0;
  69.     
  70.         //
  71.         // EventFuncName
  72.         //
  73.         // Form1::cb_1_Click
  74.         //
  75.         virtual void GetEventFuncName( WString &name ) const = 0;
  76.  
  77.         //
  78.         // DTObj
  79.         //
  80.         // Events are associated with a DTObject -- the object that
  81.         // triggers the event.
  82.         //
  83.         virtual DTObject *      GetDTObj() const = 0;
  84.  
  85.         //
  86.         // EventOwner is separate from the DTObj.  I hope that it
  87.         // is obsolete.
  88.         //
  89.         virtual void  SetEventOwner( DTObject * owner ) = 0;
  90.  
  91.         //
  92.         // Open the event in a code editor
  93.         //
  94.         virtual WBool EditEvent( WBool visible = TRUE ) = 0;
  95.  
  96.         //
  97.         // SourceLine
  98.         //
  99.         // These are used to determine where in the generted code
  100.         // file an event is.  Necessary for debugging.
  101.         //
  102.         virtual void    SetSourceLine( int line ) = 0;
  103.         virtual int     GetSourceLine( void ) const = 0;
  104.  
  105.         //
  106.         // Save/Load
  107.         //
  108.         // An Event can request an additional block in the .wxf
  109.         // file by returning TRUE from HasSaveInfo; then a block
  110.         // is created and Save is called.
  111.         //
  112.         virtual WBool HasSaveInfo() = 0;
  113.         virtual WBool Save( SaveSource & save ) = 0;
  114.         virtual WBool Load( SaveBlock * load ) = 0;
  115.  
  116.         //
  117.         // TheCode
  118.         //
  119.         // GetTheCode
  120.         // If parameterized is TRUE, GetTheCode returns a parameterized
  121.         // copy of the source code which must be destroyed.  Otherwise,
  122.         // a copy of the original code is returned -- don't destroy it!
  123.         //
  124.         // SetTheCode always clears the strings out of 'code'.
  125.         //
  126.         virtual WBool   HasCode() const = 0;
  127.         virtual void    SetTheCode( WStringList & code, WBool parameterized  ) = 0;
  128.         virtual void    GetTheCode( WStringList & code, WBool parameterized  ) const = 0;
  129.  
  130.         //  ChangeCode
  131.         //
  132.         //  Update the code contained in this event.
  133.         //
  134.         virtual WBool ChangeCode( CCType type, const WString &oldName,
  135.                                   const WString &newName ) = 0;
  136.  
  137.         //
  138.         // New style code generation:
  139.         //    Prototype     -- "WBool cb_1_Click( WObject *, WEventData * );"
  140.         //    EventHandler  -- { WClickEvent, WEventHandlerCast(...) },
  141.         //    Members       -- the code lines
  142.         //
  143.         virtual void GeneratePrototype( ostream &, const WString & obj ) = 0;
  144.         virtual void GenerateEventHandler( ostream &, const WString & obj ) = 0;
  145.         virtual void GenerateMembers( ostream & ) = 0;
  146.  
  147.         //
  148.         // Order is used to control the ordering of
  149.         // events in the generated code.
  150.         //
  151.         virtual WInt    GetOrder() const = 0;
  152.         virtual void    SetOrder( WInt ) = 0;
  153.  
  154.         //
  155.         // Scope
  156.         // - public/protected/private/generated public/private protected
  157.         //
  158.         virtual UFScope GetScope() const = 0;
  159.         virtual void    SetScope( UFScope ) = 0;
  160.  
  161.         //
  162.         // GenCode
  163.         //
  164.         // True if this is a generated code block.  It will only be shown
  165.         // if the user has ShowReadOnly. If shown, it will be read only.
  166.         //
  167.         virtual WBool GetGenCode() const = 0;
  168.         virtual void  SetGenCode( WBool ) = 0;
  169.  
  170.         //
  171.         // IsPrototype
  172.         //
  173.         // True if this code block is a function prototype
  174.         //
  175.         virtual WBool GetIsPrototype() const = 0;
  176.         virtual void  SetIsPrototype( WBool proto = TRUE ) = 0;
  177.  
  178.         //
  179.         // AssociatedPrototype and AssociatedDefinition
  180.         //
  181.         // Get the associated prototype if this is a definition block,
  182.         // or get the associated definition if this is a prototype block.
  183.         //
  184.         virtual DTCodeBlockBase * GetAssociatedPrototype() const = 0;
  185.         virtual DTCodeBlockBase * GetAssociatedDefinition() const = 0;
  186.         virtual void SetAssociatedPrototype( DTCodeBlockBase * ) = 0;
  187.         virtual void SetAssociatedDefinition( DTCodeBlockBase * ) = 0;
  188.  
  189.         //
  190.         // UserFunction
  191.         //
  192.         virtual UserFunction * GetUserFunction() = 0;
  193.  
  194.         //
  195.         // SpecialBlockID
  196.         //
  197.         // If this is a special block (HPP Prefix, etc.), then
  198.         // return its id.  Otherwise, return CMCNumBlocks
  199.         //
  200.         virtual CMCodeBlock GetSpecialBlockID() const = 0;
  201.         virtual void        SetSpecialBlockID( CMCodeBlock ) = 0;
  202.  
  203.         //
  204.         // GenerationFile
  205.         //
  206.         // The GenerationFile is the file that the code is emitted
  207.         // into.  Can be CMFileHPP, CMFileCPP, CMFileJava
  208.         //
  209.         virtual CMFile  GetGenerationFile() const = 0;
  210.         virtual void    SetGenerationFile( CMFile ) = 0;
  211. };
  212.  
  213. class DTUserFunctionVect : public WSortableVector< DTCodeBlockBase > {};
  214.  
  215. //typedef WCPtrSortedVector< DTCodeBlockBase > DTCodeBlockList;
  216. class  DTCodeBlockList :  public WCPtrSortedVector< DTCodeBlockBase > {};
  217.  
  218. class  DTCodeBlockListList :  public WCPtrOrderedVector< DTCodeBlockList > {};
  219.  
  220. #endif // _DTCODEBK_HPP
  221.